﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using KPIS.GERP.Models;
using KPIS.GERP.Models.HRM;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using KPIS.GERP.Models;
using KPIS.GERP.Models.HRM;
using KPIS.GERP.Models.SYS;
using System.Data.Entity;

namespace KPIS.GERP.WCF.GHRMS
{
    [ServiceContract]
    public interface IWorkOnDutyService
    {
        [OperationContract]
        List<MpPositionWorkOnDuty> Select(int byEmpId);
    }
    
    public class WorkOnDutyService : IWorkOnDutyService
    {
        public List<MpPositionWorkOnDuty> Select(int byEmpId)
        {
            using(var db = new GERPContext(false))
            {
                var data = db.MpPositionWorkOnDuties.
                    Include(o=>o.ToPosition).Include(o=>o.ByEmployee).
                    Where(o => o.RecordStatus == RecordStatus.ApprovedStatus &&
                               o.StartDate <= DateTime.Now &&
                               o.EndDate >= DateTime.Now &&
                               o.ByEmpSeq == byEmpId).ToList(); 
                return data;
            }
        }
    }
}
